package com.sm.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sm.dao.ListenMapper;
import com.sm.model.ListenEveryday;
import com.sm.util.PageResult;
import com.sm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ListenService {
   @Autowired
    private ListenMapper listenMapper;
    public PageResult pageQuery(Integer currentPage, Integer pageSize, String
            queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page page = listenMapper.selectByCondition(queryString);
        return new  PageResult(page.getTotal(),page.getResult());
    }

    /**
     * 获取每日一听详情
     */
    public ListenEveryday selectOne(Integer id){
        return listenMapper.selectOne(id);
    }

    /**
     * 获取上一条下一条的id
     */
    public Integer getBefore(Integer id){
        return listenMapper.getBefore(id);
    }
    /**
     * 获取下一条的id
     */
    public Integer getAfter(Integer id){
        return listenMapper.getAfter(id);
    }

}
